package com.twu.biblioteca;

import java.io.IOException;
import java.util.Map;

public class ListMenuItem implements MenuItem {
    private InteractiveConsole console;
    private Map<Integer, String> library;

    public ListMenuItem(InteractiveConsole console, Map<Integer, String> library) {
        this.console = console;
        this.library = library;
    }

    @Override
    public void start() throws IOException {
        for (Map.Entry<Integer, String> book : library.entrySet()) {
            console.println(String.format("(%d) %s", book.getKey(), book.getValue()));
        }
    }

    @Override
    public String toString() {
        return "List all books about killing all humans.";
    }
}
